package 剑指offer;

public class 剑指Offer530n到1中缺失的数字 {
    public static void main(String[] args) {
        int[] arr = new int[]{0};
        System.out.println(missingNumber(arr));
    }
    public static int missingNumber(int[] nums) {
        if (nums[nums.length - 1] == nums.length-1){
            return nums.length;
        }
        return order(nums,0,nums.length-1);
    }
    public static int order(int[] num,int l,int r){
        while (l < r){
            int mid = (l + r)/2;
            if (mid == num[mid]){
                //此时前num个都相等，则向有查找
                return order(num,mid+1,r);
            }else {
                //向左查找
                return order(num,l,mid);
            }
        }
        return l;
    }
}
